#include <stdio.h>
#include <string.h>

int canculate(char *ch, int number)
{
    int result = 0;
    int t[27] = {0};
    for (int i = 0; i < strlen(ch); i++)
    {
        t[*ch - 'a' + 1] = 1;
    }

    for (int i = 0; i < 27; i++)
    {
        int temp = 0;
        if (t[i] == 1)
        {
            if (temp > number)
            {
                temp--;
                result--;
            }
            else if (temp < number)
            {
                temp += i;
                result++;
            }
            else
            {
                continue;
            }
        }
    }

    return result;
}

int main()
{
    char ch[1024];
    // printf("%d",sizeof(numbers));
    if (scanf("%s", ch) != EOF)
    {
        int number = 0;
        if (scanf("%d", &number) != EOF)
        {
            printf("%d\n", canculate(ch, number));
        }
    }
    return 0;
}